# -*- coding: utf-8 -*-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<%
  errors = []
  if request.environ.get("FAILED_AUTHENTICATION"):
	  errors.append("Login or password incorrect.")
  if c.form_errors:
    errors.append("Please correct the errors bellow.")
%>

## To prevent importing two times a javascript file
<% self.seen_javascripts = set() %>
<%def name="javascript_link(*paths)">
  % for path in paths: 
    % if path not in self.seen_javascripts:
      ${h.javascript_include_tag(path)} \
      <% self.seen_javascripts.add(path) %>
    % endif
  % endfor
</%def>

<%def name="javascript()">
  ${self.javascript_link('jquery',
                         'tools',
                         )}
  % if request.environ.get("REMOTE_USER_OBJ") is None:
    ${self.javascript_link(
    'jquery.debug.js', 
    'jquery.validate.js', 
    'jquery.json-1.2.js', 
    'jquery.watermark.js',
    'authform')} \
  % endif
</%def>

## To prevent importing two times a CSS file
<% self.seen_CSSs = set() %>
<%def name="css_link(*paths)">
  % for path in paths: 
    % if path not in self.seen_CSSs:
      ${h.stylesheet_link_tag(path)} \
      <% self.seen_CSSs.add(path) %> \
    % endif
  % endfor
</%def>

<%def name="css()">
  ${self.css_link('base')} \
  ${self.css_link('header')} \
  ${self.css_link('form')} \
  ${self.css_link('footer')} \
  ${self.css_link('menu')} \
</%def>

## What javascript do we execute when the DOM is ready?
## <% self.dom_onLoad_list = [] %>
<%def name="dom_onLoad()">
  % if request.environ.get("REMOTE_USER_OBJ") is None:
  	$('#wsgilogin').watermark({html:'Login',cls:'pad empty'});
  	$('#wsgipassword').watermark({html:'Password',cls:'pad empty'});
  % endif
</%def>

<head>
    <title>Ciby-Net Administration</title> \
    ${self.css()} \
    ${self.javascript()} \
##    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
<div id="pagewrapper">

<div id="headerwrapper">
  <div id="header">

  <div id="topmenu">
  <%include file="/menu.mako"/>
  %if False:
  	<span class="topmenu"><a href="${h.url_for('home')}">Home</a></span>
    <span class="topmenu"><a href="${h.url_for('students')}">Students</a></span>
    <span class="topmenu"><a href="${h.url_for('rooms')}">Rooms</a></span>
    <span class="topmenu"><a href="${h.url_for('buildings')}">Buildings</a></span>
    <span class="topmenu"><a href="${h.url_for('machines')}">Machines</a></span>
  %endif
  </div>
  
  <div class="authenticationbox">
	% if request.environ.get("REMOTE_USER_OBJ"):
	  <div id="authentication_name_logout">
		<%namespace name="student_comps" file="/students/components.mako"/>
		${student_comps.link_to(request.environ.get("REMOTE_USER_OBJ"))} | 
		${h.link_to("Sign out", g.SIGNOUT_PART)}
	  </div>
	% else:
		<%include file="/login/miniform.mako"/>
	% endif
  </div>
  
  <div id="headerline"></div>
  
  </div>
</div>

<div id="bodywrapper">
	## Display errors box?
	% if errors:
		<div id="error_msgs_box_wrapper">
			<div id="error_msgs_box">
				${"<br/>".join(errors)}			
			</div>
		</div>
	% else:
		<div id="error_msgs_box_wrapper" style="display:none">
	    	<div id="error_msgs_box"></div>
		</div>
	% endif
    ${ next.body() }
</div>
## In case all the elements of the body are relative, we need this:
<div class="breakline"></div>

<div id="footerbuffer"></div>
<div id="footerwrapper">
  	<div class="bottomshadow"> </div>
  	<div id="footer">
  	<a href="${g.FEEDBACK_PART}"> Make a comment about this page </a> -
  	${h.mail_to('"Ciby-Net" <%s>' % g.cibynet_email, "Contact us")}
  	</div>
</div>
</div>

##% if self.dom_onLoad:
## TODO: don't put anything is there is nothing to execute?
  <script type="text/javascript">
  <!--
    $(document).ready(function() { ${self.dom_onLoad()} });
  -->
  </script>
##% endif
  
</body>
</html>


